package com.hot100.mid;

/**
 * @author zhengTao
 * @version 1.0
 * @description: 不同的二叉搜索树
 * @date 2022/8/21 14:21
 */
public class Demo25 {
    public static void main(String[] args) {
        int i = numTrees(4);
        System.out.println(i);
    }
    public static  int numTrees(int n) {
          int[] num=new int[n+1];
          if(n<0){
              return 0;
          }
        if(n==1){
            return 1;
        }
        num[0]=1;
        num[1]=1;
        for (int i = 2; i < num.length; i++) {
            for (int j = 1; j <=i; j++) {
                num[i]+=num[j-1]*num[i-j];
            }
        }
        return num[n];
    }
}
